/**
 * 统一管理ajax的请求，也就是说所有的ajax请求路径都在此处进行统一维护
 */

// 引入二次封装好的axios对象
import ajax from './ajax'
import mockAjax from '@/mock/mockAjax'
// 定义获取三级导航的接口函数
// 带Listdata表示响应回来的数据是数组格式
// req开头，一般表示一个请求的函数
// export const reqGetCategoryListData = () => {
//   return ajax.get('/api/product/getBaseCategoryList')
// }
// 上面的函数，简写成如下形式
export const reqGetCategoryListData = () => ajax.get('/api/product/getBaseCategoryList')

// 发送请求，获取banner数据
export const reqGetBannerListData = () => mockAjax.get('/banner')

// 发送请求，获取floor数据
export const reqGetFloorsListData = () => mockAjax.get('/floor')
// 发送请求获取搜索数据
export const reqGetSearchGoodsInfoData = (searchParams) => ajax.post('/api/list',searchParams)
// 获取商品详情页的数据
export const reqGetGoodDetailInfoData = (id) => ajax.get('/api/item/' + id)
// 添加商品到购物车或是更新购物车
export const reqAddOrUpdateCart = (skuId, skuNum) => ajax.post(`/api/cart/addToCart/${skuId}/${skuNum}`)
// 获取购物车商品数据
export const reqGetShopCartListData = ()=> ajax.get('/api/cart/cartList')
// 设置购物车中商品的选中状态
export const reqChangeShopCartInfoState = (skuID,isChecked)=> ajax.get(`/api/cart/checkCart/${skuID}/${isChecked}`)

// 批量更新购物车商品的选中状态
export const reqUpdateAllShopCartInfoState = (skuIdList,isChecked) => ajax.post(`api/cart/batchCheckCart/${isChecked}`,skuIdList)

// 删除一条购物车的数据
export const reqDelOneShopCartInfo = (skuId) => ajax.delete(`/api/cart/deleteCart/${skuId}`)

// 批量删除购物车中的商品数据
export const reqDelSelectedCartInfo = skuIdList=> ajax.delete(`/api/cart/batchDeleteCart`,skuIdList)

// 获取手机验证码
export const reqGetVerifyCode = (phone) => ajax.get(`/api/user/passport/sendCode/${phone}`)

// 注册用户
export const reqUerRegister = userObj => ajax.post('/api/user/passport/register', userObj)

// 登陆
export const reqUserLogin = userObj => ajax.post('/api/user/passport/login', userObj)

// 登出
export const reqUserLogout = () => ajax.get('/api/user/passport/logout')

// 16.获取用户的送货地址
export const reqGetUserAddressList = () =>ajax.get('/api/user/userAddress/auth/findUserAddressList')

// 17.获取用户要支付的商品信息
export const reqGetTradeInfoData = ()=>ajax.get('/api/order/auth/trade')

// 18. 提交订单
export const reqSubmitTradeOrder =(tradeNo,params)=>ajax.post(`/api/order/auth/submitOrder?tradeNo=${tradeNo}`,params)

